<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
      text-decoration: none;
      background-color: black;
    }
    a{
      display: block;
      width: 150px;
      height: 40px;
      background-color: gold;
      border-radius: 10px;
      text-align: center;
      line-height: 40px;
      color:white;
      font-weight: 700;
      margin: 20px auto;
    }
    ul{
      width: 500px;
      margin: 0 auto;
    }
    li{
      width: 100px;
      height: 100px;
      float: left;
    }
    img{
      width: 100%;
      height: 100%;
      transition: all 1s linear;
    }
    .change{
      transform: scale(1.5,1.5)
    }
  </style>
</head>
<body>
  <a href="javaScript:void(0)">创建英雄列表</a>
  <script>
    var data = [
      {imgsrc:"img/01.jpg",imgtitle:"司马懿1"},
		  {imgsrc:"img/02.jpg",imgtitle:"司马懿2"},
		  {imgsrc:"img/03.jpg",imgtitle:"司马懿3"},
		  {imgsrc:"img/04.jpg",imgtitle:"司马懿4"},
		  {imgsrc:"img/05.jpg",imgtitle:"司马懿5"},
		  {imgsrc:"img/06.jpg",imgtitle:"司马懿6"},
		  {imgsrc:"img/07.jpg",imgtitle:"司马懿7"},
		  {imgsrc:"img/08.jpg",imgtitle:"司马懿8"},
		  {imgsrc:"img/09.jpg",imgtitle:"司马懿9"},
		  {imgsrc:"img/10.jpg",imgtitle:"司马懿10"},
		  {imgsrc:"img/11.jpg",imgtitle:"司马懿11"},
		  {imgsrc:"img/12.jpg",imgtitle:"司马懿11"},
		  {imgsrc:"img/13.jpg",imgtitle:"司马懿11"},
		  {imgsrc:"img/14.jpg",imgtitle:"司马懿11"},
		  {imgsrc:"img/15.jpg",imgtitle:"司马懿11"},
		  {imgsrc:"img/16.jpg",imgtitle:"司马懿11"}
    ];
    var body = document.querySelector('body');
    var ul;
    var li;
    var img;
    var a_btn = document.querySelector('a');
    a_btn.onclick = function(){
      if(document.querySelector(ul)){
        return;
      }
      ul = document.createElement('ul');
      for(var i = 0; i < data.length; i++){
        li = document.createElement('li');
        img = document.createElement('img');
        img.src = data[i].imgsrc;
        img.title = data[i].imgtitle;
        
        img.onmouseenter = function(){
          this.className = 'change';
        }
        img.onmouseleave = function(){
          this.className = '';
        }
               
        li.appendChild(img);
        ul.appendChild(li);
      }
      body.appendChild(ul);
    }
  </script>
</body>
</html>